﻿
<script>
    var tempmodel = avalon.define({
        $id: "KHGL",
        name: "客户管理",
        ColumnData: [],
        modelData: (!pmodel.pageType && localStorage.getItem(pmodel.FormCode)) ? $.parseJSON(localStorage.getItem(pmodel.FormCode)) :{ "KHLeiBie": "", "KHXinBie": "先生", "KHName": "", "KHZhiWu": "", "KHPhone": "", "KHFXRS": ComFunJS.getnowuser(), "KHDW": "", "KHAdress": "", "Files": "", "Remark": "", "KHZJ": "", "KHEmail": "", "KHJTZZ": "", },
        iswf: false,//是否属于流程表单
        inittemp: function (strId) {
            $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: 8 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.ColumnData = resultData.Result;
                    if (!tempmodel.modelData.KHLeiBie && tempmodel.ColumnData.size()>0) {
                        tempmodel.modelData.KHLeiBie = resultData.Result[0].TypeNO; 
                    } 
                }
            }) 
            if (strId) {
                //编辑加载数据
                $.getJSON('/API/FTAPI.ashx?Action=GETKHGLMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        setTimeout(" ComFunJS.initForm()", 500)
                    }
                })
            } else { 
                ComFunJS.initForm();
            }
        },//初始化
        SaveData: function (btdom, piid) {
            var data = tempmodel.modelData.$model;
            var modelValue = JSON.stringify(data);
            $.post("/API/FTAPI.ashx?ACTION=ADDKHGL", { P1: modelValue }, function (result) {
                var jsonresult = $.parseJSON(result)
                btdom.removeClass("disabled").find("i").hide();
                if ($.trim(jsonresult.ErrorMsg) == "") {
                    ComFunJS.winsuccessnew("操作成功");
                }
            });
        },
    });
    tempmodel.$watch("modelData.*", function (a, b) {
        if (!tempmodel.modelData.ID) {
            localStorage.setItem(pmodel.FormCode, JSON.stringify(tempmodel.modelData.$model));
        }
    })
</script>
<div class="form-horizontal" ms-controller="KHGL">
    <div class="form-group">
        <label class="col-xs-2 control-label"> <span class="Required">*</span>客户种类 </label>
        <div class="col-xs-3">
            <select ms-duplex="modelData.KHLeiBie" class="form-control">
                <option ms-attr-val="item.TypeNO" ms-repeat-item="ColumnData">{{item.TypeNO}}</option>
            </select>
        </div>
        <label class="col-xs-2 control-label">客户性别</label>
        <div class="col-xs-3">
            <select ms-duplex="modelData.KHXinBie" class="form-control szhl_require">
                <option value="先生">先生</option>
                <option value="女士">女士</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label"><span class="Required">*</span>客户名称</label>
        <div class="col-xs-3">
            <input type="text" value="" ms-duplex="modelData.KHName" class="form-control szhl_require" />
        </div>
        <label class="col-xs-2 control-label">职务</label>
        <div class="col-xs-3">
            <input type="text" value="" ms-duplex="modelData.KHZhiWu" class="form-control " />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label"><span class="Required">*</span>手机号</label>
        <div class="col-xs-3">
            <input type="text" value="" ms-duplex="modelData.KHPhone" class="form-control szhl_require szhl_Phone" />
        </div>
        <label class="col-xs-2 control-label">座机</label>
        <div class="col-xs-3">
            <input type="text" value="" ms-duplex="modelData.KHZJ" class="form-control " />
        </div>
    </div>
    <div class="form-group">
       
        <label class="col-xs-2 control-label">邮箱</label>
        <div class="col-xs-3">
            <input type="text" value="" ms-duplex="modelData.KHEmail" class="form-control " />
        </div>
        <label class="col-xs-2 control-label"><span class="Required">*</span>所属单位</label>
        <div class="col-xs-3">
            <input type="text" value="" ms-duplex="modelData.KHDW" class="form-control szhl_require" />
        </div>
    </div>
   
    <div class="form-group">
        <label class="col-xs-2 control-label"><span class="Required">*</span>联系地址</label>
        <div class="col-xs-8">
            <input type="text" value="" ms-duplex="modelData.KHAdress" class="form-control szhl_require" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">家庭住址</label>
        <div class="col-xs-8">
            <input type="text" value="" ms-duplex="modelData.KHJTZZ" class="form-control " />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">客户负责人员</label>
        <div class="col-xs-8">
            <input type="text" value="" ms-duplex="modelData.KHFXRS" class="form-control szhl_getPeoples" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">备注</label>
        <div class="col-xs-8">
            <textarea id="conNR" ms-duplex="modelData.Remark" class="szhl_UEEDIT form-control "></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">附件</label>
        <div class="col-xs-9">
            <input type="text" value="" class="span2  szhl_Upload form-control" ms-duplex="modelData.Files" />
        </div>
    </div>
</div>
